package easy.RemoveDuplicatesFromSortedList;

public class RemoveDuplicatesFromSortedList {
    public ListNode deleteDuplicates(ListNode head) {
        if(head==null) return null;
        if(head.next==null) return head;
        ListNode tempNode = head;
        while(tempNode !=null && tempNode.next!=null){
            if(tempNode.val == tempNode.next.val){
                tempNode.next = tempNode.next.next;
                tempNode = tempNode.next;
            }else{
                tempNode = tempNode.next;
            }
        }
        return head;
    }
}
